package cn.lzg.client.module.user.handler;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

//import com.rc.frames.MainFrame;

import cn.lzg.common.core.model.ResultCode;
import cn.lzg.common.module.user.response.UserResponse;
import cn.lzg.ui.frames.LoginFrame;

@Component
public class UserHandlerImpl implements UserHandler {

	@Autowired
	private LoginFrame loginFrame;

	@Override
	public void login(int reultCode, byte[] data) {
		if (reultCode == ResultCode.SUCCESS) {
			UserResponse response = new UserResponse();
			response.readFromBytes(data);
			System.out.println("server发来:");
			System.out.println(response.getUsername());
			System.out.println(response.getAvatar().getFilename());
			//登陆成功
			loginFrame.successLogin(response);
		} else {
			//登陆失败
			loginFrame.onFailed();
		}
	}

	@Override
	public void register(int resultCode, byte[] data) {
		if (resultCode == ResultCode.SUCCESS) {

		} else {

		}
	}

}
